<?php
// 删除报名作品
namespace Beerus\Modules\DesignerCompetition2024\Actions;

use Doraemon\model\ReDesignerCompetition\Sign\DcUserSignHelper;
use Doraemon\pockets\constInterface\Designer\DesignerCompetition2024;
use Illuminate\Http\Request;
use Encore\Admin\Actions\RowAction;

class SignDelete extends RowAction implements DesignerCompetition2024 {
    public $name = '删除报名作品';

    public function handle($signId) {
        if (!(DcUserSignHelper::getInstance(self::SIGN_YEAR))->delSignById($signId)) {
            return $this->response()->error('删除失败')->refresh();
        }
        return $this->response()->success('删除成功')->refresh();
    }

    public function retrieveModel(Request $request) {
        if (!$key = $request->get('_key')) {
            return false;
        }
        return $key;
    }

    public function dialog() {
        $this->confirm('确定删除该作品？');
    }
}
